<template>
	<!-- 轮播图 -->
	<view class="u-wrap">
		<swiper class="swipper-container" circular :indicator-dots="indicatorDots" :indicator-color='indicatorColor'
			:autoplay="autoplay" :interval="interval" :duration="duration">
			<swiper-item v-for="(item, index) in swipperList" :key="index">
				<image class="imgs" :src="item.image"></image>
			</swiper-item>
		</swiper>
	</view>
	<!-- 搜索框 -->
	<view class="tab-strickt">
		<u-search bgColor="#f1f4ef" margin="8px" style="flex-grow: 1;" :show-action="true" action-text="搜索"
			:animation="true"></u-search>
	</view>
	<!-- 瀑布流列表 -->
	<view class="wrap">
		<u-waterfall v-model="flowList" ref="uWaterfall">
			<template v-slot:left="{leftList}">
				<view class="demo-warter" v-for="(item, index) in leftList" :key="index">
					<!-- 警告：微信小程序中需要hx2.8.11版本才支持在template中结合其他组
	件，比如下方的lazy-load组件 -->
					<u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
					<view class="demo-title">
						{{item.title}}
					</view>
					<view class="demo-price">
						{{item.price}}元
					</view>
					<view class="demo-tag">
						<view class="demo-tag-owner">
							自营
						</view>
						<view class="demo-tag-text">
							放心购
						</view>
					</view>
					<view class="demo-shop">
						{{item.shop}}
					</view>
				</view>
			</template>
			<template v-slot:right="{rightList}">
				<view class="demo-warter" v-for="(item, index) in rightList" :key="index">
					<u-lazy-load threshold="-450" border-radius="10" :image="item.image" :index="index"></u-lazy-load>
					<view class="demo-title">
						{{item.title}}
					</view>
					<view class="demo-price">
						{{item.price}}元
					</view>
					<view class="demo-tag">
						<view class="demo-tag-owner">
							自营
						</view>
						<view class="demo-tag-text">
							放心购
						</view>
					</view>
					<view class="demo-shop">
						{{item.shop}}
					</view>
				</view>
			</template>
		</u-waterfall>
		<u-loadmore bg-color="rgb(240, 240, 240)" :status="loadStatus" @loadmore="addRandomData"></u-loadmore>
	</view>
</template>
<script setup>
	import {
		ref
	} from 'vue';

	// 轮播图配置
	const indicatorDots = ref(true);
	const indicatorColor = ref("#FFF");
	const autoplay = ref(true);
	const interval = ref(2000);
	const duration = ref(500);
	const swipperList = ref([{
			image: 'https://ts1.cn.mm.bing.net/th?id=OIP-C.zJzrwcLZScgkJsVEkAd_zAHaHa&w=179&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2'
		},
		{
			image: 'https://www.bing.com/th/id/OGC.88388913c16e4d4adca7022e1ea1f938?pid=1.7&rurl=https%3a%2f%2fs1.aigei.com%2fsrc%2fimg%2fgif%2fff%2fff90333a147349499a705a15ebf0b301.gif%3fimageMogr2%2fauto-orient%2fthumbnail%2f!282x320r%2fgravity%2fCenter%2fcrop%2f282x320%2fquality%2f85%2f%26e%3d1735488000%26token%3dP7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL%3aq2jnU1xh3NVcNHZ5ucxIRtWx3GM%3d&ehk=6YPY1M%2btMm4wPuu2ZhXcIFqV1b1x4Esc7Hp%2b2Jj5VDo%3d'
		},
		{
			image: 'https://www.bing.com/th/id/OGC.453a369e76e5d2685a949721a8b4a337?pid=1.7&rurl=https%3a%2f%2fres.remeins.com%2fresimg%2f2022%2fcd71184f9989c66b41df91c756ec5312%2f453a369e76e5d2685a949721a8b4a337.jpg&ehk=L33cJ%2fzs9tLJybz%2foUsX16zvx9nxNhBJ2gKjYozNrJs%3d'
		},
		{
			image: 'https://video.acwing.com/image/default/8C152D5764A44FF7833901C322F9A119-6-2.jpg?auth_key=1735776000-ac2870wing-0-3fe725635fd3966a703b4bdbe00dc041'
		},
		{
			image: 'https://video.acwing.com/image/default/1A1933CEC4214DAE9010F2AB8120FD19-6-2.jpg?auth_key=1735776000-ac2870wing-0-4ef366ed1d4133f99d67a164bd452002'
		},
		{
			image: 'https://video.acwing.com/image/default/0AD8EF5FC86F4ACD8127CD09B69C4807-6-2.jpg?auth_key=1735776000-ac2870wing-0-e95ae8de7d0480f03b17a382fa733146'
		}
	]);

	//瀑布流数据
	const flowList = ref([{
			price: 75,
			title: '笔记本电脑',
			image: 'https://tse3-mm.cn.bing.net/th/id/OIP-C.T1SMaKa_CO1kGBytmZKLvgHaHa?rs=1&pid=ImgDetMain',
		},
		{
			price: 385,
			title: '华为手机',
			image: 'https://cdn.acwing.com/media/article/image/2024/12/24/134627_7954eebec1-%E7%94%9F%E6%88%90%E5%8D%8E%E4%B8%BA%E6%89%8B%E6%9C%BA%E5%9B%BE%E7%89%87.png',
		},
		{
			price: 784,
			title: '台式电脑',
			image: 'https://ts1.cn.mm.bing.net/th?id=OIP-C.Cgj2NnmD5AdC9Eu94wrrJAHaFw&w=176&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
		},
		{
			price: 7891,
			title: '电脑',
			image: 'https://ts1.cn.mm.bing.net/th?id=OIP-C.xjBjgayWEdBmxnT8AkHgEQHaHB&w=177&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
		},
		{
			price: 2341,
			title: '自行车',
			image: 'https://ts1.cn.mm.bing.net/th?id=OIP-C.cQcc4Y5nReS5k7lXtTaRLAHaEK&w=181&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
		},
		{
			price: 2342,
			title: '考研英语',
			image: 'https://cn.bing.com/th?id=OPAC.d4xE5jMTRymQ9Q474C474&o=5&pid=21.1&w=160&h=160&qlt=100&dpr=1.3&c=8&pcl=f5f5f5',
		},
		{
			price: 2341,
			title: '苹果手机',
			image: 'https://ts1.cn.mm.bing.net/th?id=OIP-C.k0ipVLg9rgSxJb_XfwSrBgHaHa&w=176&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
		},
		{
			price: 2342,
			title: '小米电视',
			image: 'https://ts2.cn.mm.bing.net/th?id=OIP-C.cAI08oWuZ21pLMBRP3DknwHaMD&w=195&h=318&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2',
		}
	])
</script>


<style lang="scss" scoped>
	.swipper-container {
		height: 180px;
	}

	.imgs {
		height: 180px;
		width: 100%;
	}

	.demo-warter {
		border-radius: 8px;
		margin: 5px;
		background-color: #ffffff;
		padding: 8px;
		position: relative;
	}

	.u-close {
		position: absolute;
		top: 32rpx;
		right: 32rpx;
	}

	.demo-image {
		width: 100%;
		border-radius: 4px;
	}

	.demo-title {
		font-size: 30rpx;
		margin-top: 5px;
		color: $u-main-color;
	}

	.demo-tag {
		display: flex;
		margin-top: 5px;
	}

	.demo-tag-owner {
		background-color: $u-type-error;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}

	.demo-tag-text {
		border: 1px solid $u-type-primary;
		color: $u-type-primary;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}

	.demo-price {
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
	}

	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}
</style>